/*    */ package com.controller.back;
/*    */ 
/*    */ import base.utils.PagingResult;
/*    */ import com.model.Admin;
/*    */ import com.model.Hotel;
/*    */ import com.model.Users;
/*    */ import com.service.HotelService;
/*    */ import com.service.UserService;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpSession;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.servlet.ModelAndView;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"adminHotel"})
/*    */ public class AdminHotelController
/*    */ {
/*    */   @Autowired
/*    */   private HotelService hotelService;
/*    */   @Autowired
/*    */   private UserService userService;
/*    */   
/*    */   @RequestMapping({"index"})
/*    */   public ModelAndView getHoletList(HttpServletRequest request)
/*    */   {
/* 40 */     ModelAndView mv = new ModelAndView();
/*    */     
/* 42 */     String page = (request.getParameter("page") == null) || 
/* 43 */       ("".equals(request.getParameter("page"))) ? "1" : request
/* 44 */       .getParameter("page");
/* 45 */     String size = (request.getParameter("size") == null) || 
/* 46 */       ("".equals(request.getParameter("size"))) ? "20" : request
/* 47 */       .getParameter("size");
/*    */     
/* 49 */     HttpSession session = request.getSession();
/* 50 */     Admin t = (Admin)session.getAttribute("admin_user");
/* 51 */     if (t == null) {
/* 52 */       mv.setViewName("redirect:/manage/managelogin.do");
/* 53 */       return mv;
/*    */     }
/*    */     
/* 56 */     String[] clause = { "Hotel.*", "Users.*" };
/* 57 */     String sql = " LEFT JOIN Users ON Users.user_id = Hotel.hotel_userid  WHERE Users.deleteFlag=0 AND Hotel.deleteFlag=0 ";
/*    */     
/* 59 */     Object[] obj = new Object[0];
/* 60 */     PagingResult pr = this.hotelService.selectBySqlPaging(clause, sql, obj, Integer.valueOf(Integer.parseInt(page)), Integer.valueOf(Integer.parseInt(size)));
/* 61 */     List<Map<?, ?>> list = pr.getResultList();
/* 62 */     int h = (Integer.parseInt(page) - 1) * Integer.parseInt(size);
/* 63 */     mv.addObject("ss", Integer.valueOf(h));
/* 64 */     mv.addObject("list", list);
/* 65 */     mv.addObject("page", page);
/* 66 */     mv.addObject("size", size);
/* 67 */     mv.addObject("total", Integer.valueOf(pr.getTotalSize()));
/* 68 */     mv.addObject("url", "/back/hotel/index.jsp");
/* 69 */     mv.setViewName("/index.jsp");
/* 70 */     return mv;
/*    */   }
/*    */   
/*    */   @RequestMapping({"show"})
/*    */   public ModelAndView show(HttpServletRequest request)
/*    */   {
/* 76 */     ModelAndView mv = new ModelAndView();
/*    */     
/* 78 */     String hotel_id = request.getParameter("hotel_id");
/*    */     
/* 80 */     Hotel hotel = (Hotel)this.hotelService.selectByPrimaryKey(hotel_id);
/* 81 */     Users user = (Users)this.userService.selectByPrimaryKey(hotel.getHotel_userid()+"");
/* 82 */     mv.addObject("hotel", hotel);
/* 83 */     mv.addObject("user", user);
/* 84 */     mv.addObject("url", "/back/hotel/show.jsp");
/* 85 */     mv.setViewName("/index.jsp");
/* 86 */     return mv;
/*    */   }
/*    */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\back\AdminHotelController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */